/*-----------------
    弹出对话框功能
------------------*/ 
define(function(require,exports,module){
    var url = require('mod-url');
    var $ = require("$");
    require('easyui');
    require('easyui-css');
    require('easyui-icon-css');
	function ConsultDialog(obj){
		this.obj = obj;
	}
	
	module.exports = ConsultDialog;
	
	ConsultDialog.prototype.showAnswer = function(){
		var obj = this.obj;

		var $this = $(obj);//咨询对象
		var $dialog = $("#consult-dialog");//对话框
		var $close = $dialog.find(".consult-dialog-close");//关闭按钮
		var $head = $dialog.find(".consult-dialog-hd");//对话框标题栏

		//关闭对话框
		$close.click(function(){
			$dialog.addClass("fn-hide");
		});

		//点击咨询链接显示对话框
		$this.find("li").click(function(){
			var title = $(this).children("a").attr("title");
			var aid = $(this).children("a").attr("aid");

			if (!aid) {
				alert('信息传递错误, 请重新操作!');
			} else {
				$.getJSON(url.liveAjax+"?callback=?",{ 'action':'answer', 'aid':aid },function(data){
					if (data) {
						$('#dialog p').text(data);
						$('#dialog h3').text(title);
						$("#dialog").dialog({
                            title:"详情",
                            closed:true,
                            modal:true,
                            width: 450
                        });
                        $("#dialog").dialog('open');
					}
				});
			}
		});
	}
});